#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> Discretize(vector<int>& viInput) {
    vector<int> viSorted = viInput;
    sort(viSorted.begin(), viSorted.end());
    auto vLast = unique(viSorted.begin(), viSorted.end());
    viSorted.erase(vLast, viSorted.end());

    vector<int> viResult;
    for (int iElement : viInput) {
        auto it = lower_bound(viSorted.begin(), viSorted.end(), iElement);
        viResult.push_back(it - viSorted.begin() + 1);
    }
    return viResult;
}

int main() {
    vector<int> viArray = {5, 2, 8, 5, 2};
    vector<int> viDiscretized = Discretize(viArray);

    for (int iNum : viDiscretized) {
        cout << iNum << " ";
    }
    cout << endl;

    return 0;
}